[Setup]
WizardImageFile=bookworm.bmp
WizardSmallImageFile=bookworm_small.bmp
WizardImageBackColor=clWhite
WizardImageStretch=False
AppName=News Worm
AppVersion=3.2.0.0
AppCopyright=Niko Rosvall 2014
AppId={{E8DB3E38-A09D-4CF1-BBA4-D698D3A47AC5}
SetupIconFile=NewsWorm.ico
DefaultDirName={pf}\NewsWorm\
ShowLanguageDialog=no
UsePreviousGroup=False
DisableProgramGroupPage=yes
DisableDirPage=auto
AppPublisher=Niko Rosvall
AppPublisherURL=http://www.newsworm.net
AppSupportURL=http://www.newsworm.net
AppUpdatesURL=http://www.newsworm.net
AppContact=niko@newsworm.net
UninstallDisplayName=News Worm
UninstallDisplayIcon={app}\NewsWorm.exe
VersionInfoVersion=3.2.0.0
VersionInfoCompany=Niko Rosvall
VersionInfoCopyright=Niko Rosvall 2014
VersionInfoProductName=News Worm
VersionInfoProductVersion=3.2.0.0
OutputDir=Out
LicenseFile=gpl.rtf
OutputBaseFilename=SetupNewsWorm
InternalCompressLevel=none
MinVersion=0,5.1.2600
DefaultGroupName=NewsWorm
AlwaysUsePersonalGroup=true
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64
DefaultDialogFontName=Segoe UI
Compression=none

[Files]
Source: "D:\Documents\Visual Studio 2013\Projects\NewsWorm\NewsWorm\bin\Release\NewsWorm.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "D:\Documents\Visual Studio 2013\Projects\NewsWorm\NewsWorm\bin\Release\NewsWorm.exe.config"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "D:\Documents\Visual Studio 2013\Projects\NewsWorm\NewsWorm\3rdparty\FastColoredTextBox.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "D:\Documents\Visual Studio 2013\Projects\NewsWorm\NewsWorm\3rdparty\ICSharpCode.SharpZipLib.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace
Source: "D:\Documents\Visual Studio 2013\Projects\NewsWorm\Installer\GPL.txt"; DestDir: "{app}"; Flags: ignoreversion restartreplace

[Tasks]
Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"

[Icons]
Name: "{group}\News Worm"; Filename: "{app}\NewsWorm.exe"
Name: "{group}\News Worm"; Filename: "{app}\GPL.txt"
Name: "{userdesktop}\News Worm"; Filename: "{app}\NewsWorm.exe"; Tasks: desktopicon

[Registry]
Root: HKCR; Subkey: "NewsWorm"; ValueType: string; ValueData: "newsworm: Aggregator URL protocol"
Root: HKCR; Subkey: "NewsWorm"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""
Root: HKCR; Subkey: "NewsWorm\DefaultIcon"; ValueType: string; ValueData: "{app}\NewsWorm.exe.1"
Root: HKCR; Subkey: "NewsWorm\shell"
Root: HKCR; Subkey: "NewsWorm\shell\open"
Root: HKCR; Subkey: "NewsWorm\shell\open\command"; ValueType: string; ValueData: "{app}\NewsWorm.exe ""%1"" "

[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
//    'v1.1.4322'     .NET Framework 1.1
//    'v2.0.50727'    .NET Framework 2.0
//    'v3.0'          .NET Framework 3.0
//    'v3.5'          .NET Framework 3.5
//    'v4\Client'     .NET Framework 4.0 Client Profile
//    'v4\Full'       .NET Framework 4.0 Full Installation
//
// service -- Specify any non-negative integer for the required service pack level:
//    0               No service packs required
//    1, 2, etc.      Service pack 1, 2, etc. required
var
    key: string;
    install, serviceCount: cardinal;
    success: boolean;
begin
    key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
    // .NET 3.0 uses value InstallSuccess in subkey Setup
    if Pos('v3.0', version) = 1 then begin
        success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
    end else begin
        success := RegQueryDWordValue(HKLM, key, 'Install', install);
    end;
    // .NET 4.0 uses value Servicing instead of SP
    if Pos('v4', version) = 1 then begin
        success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
    end else begin
        success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
    end;
    result := success and (install = 1) and (serviceCount >= service);
end;

function InitializeSetup(): Boolean;
begin
    if not IsDotNetDetected('v4\Client', 0) then begin
        MsgBox('News Worm requires Microsoft .NET Framework 4.0 or higher.'#13#13
            'Please use Windows Update to install it,'#13
            'and then re-run the News Worm setup program.', mbInformation, MB_OK);
        result := false;
    end else
        result := true;
end; 



